package game;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;

import javax.swing.ImageIcon;

import com.golden.gamedev.object.Sprite;
/*
 * This abstract bonus class handle all types of bonuses/rewards that are alloted in the game. 
 */

public abstract class AbstractBonus extends Sprite
{
	private static final long serialVersionUID = 1L;
	String name;
    Sprite icon;
    ProgBob progBob;
    AbstractBonus next;
    protected boolean bonusBoolean = false;

    public AbstractBonus(){
    }
    
    public AbstractBonus (ProgBob progBob, String name, Sprite icon)
    {
        this.progBob = progBob;
        this.name = name;
        this.icon = icon;
    }
    
   /*
    * This class turns the bonus award operator on
    */
    protected abstract void toggleBonus(); 
    
    /*
     * This checks to make sure the bonus option is on
     */
    public abstract boolean isOn();
    public abstract void turnOff();
    public abstract void turnOn();
    
    protected ProgBob getMain(){
    	return progBob;
    }
    
    protected void setBonusPosition(int mouseX, int mouseY, int offset){
    	this.setX(mouseX - this.getWidth() / 2);
        this.setY(mouseY - this.getHeight() / 2 + offset);
    }
    
    public BufferedImage createBufferedImage(String filename) {
		ImageIcon icon = new ImageIcon(filename);
		Image image = icon.getImage();
		// Create empty BufferedImage, sized to Image
		BufferedImage buffImage = new BufferedImage(image.getWidth(null), image.getHeight(null)
				, BufferedImage.TYPE_INT_ARGB);
		// Draw Image into BufferedImage
	    Graphics g = buffImage.createGraphics();
	    g.drawImage(image, 0, 0, null);
	    g.dispose();
		return buffImage;
	}
}
